<template>
  <div class="center">
    <div class="center-view">
      <p><img src="~assets/img/download.png" alt="" /></p>
      <p @click="loginClick" v-if="loginInfo.username">{{ loginInfo.username }}</p>
      <p @click="loginClick" v-else>立即登录</p>
    </div>
    <center-tab />
    <div class="shop">
      <shop-item v-for="item in dataList" :data="item" :key="item.title" />
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
import CenterTab from './children/CenterTab.vue'
import ShopItem from './children/ShopItem'
export default {
  components: { CenterTab, ShopItem },
  name: 'Center',
  data() {
    return {
      dataList: [
        {
          title: '卖座卷',
          icon: 'icon-youhuiquan2',
          color: 'red'
        },
        {
          title: '组合红包',
          icon: 'icon-hongbao_huabanfuben',
          color: 'red'
        },
        {
          title: '余额',
          icon: 'icon-yue',
          money: '0',
          color: 'orange'
        },
        {
          title: '设置',
          icon: 'icon-shezhi1',
          color: 'skyblue'
        }
      ]
    }
  },
  methods: {
    loginClick() {
      this.$router.push('/login')
    }
  },
  computed: {
    ...mapState('loginModule', ['loginInfo'])
  }
}
</script>

<style lang="scss" scoped>
.center-view {
  text-align: center;
  margin-top: -0.44rem;
  height: 2rem;
  padding-left: 0.22rem;
  padding-top: 0.64rem;
  background: url('~assets/img/bg.png');
  background-size: cover;
  display: flex;
  align-items: center;
  color: #fff;
  img {
    height: 0.67rem;
    width: 0.67rem;
    border-radius: 50%;
    border: 0.03rem solid #ffffff;
    margin-right: 0.2rem;
  }
  p {
    font-size: 0.16rem;
  }
}
.shop {
  background: white;
}
</style>